//
//  UIButton+Extension.swift
//  05.08--weibo
//
//  Created by fennyYang on 16/5/24.
//  Copyright © 2016年 a. All rights reserved.
//

import UIKit

extension UIButton
{
     convenience init(bkgImageName: String, imageName: String, title: String, titleColor: UIColor = UIColor.lightGrayColor(), fontSize: CGFloat = 12)
     {
          // 外面不传titleColor就十一默认的参数
          // 先调用当前类的指定或便利构造函数创建对象，创建完对象后给对象设置参数
          self.init(type: UIButtonType.Custom)

          // 设置
          self.setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)

          self.setBackgroundImage(UIImage(named: "\(bkgImageName)_highlighted"), forState: UIControlState.Highlighted)


          self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)


          self.setTitle(title, forState: UIControlState.Normal)

          self.setTitleColor(titleColor, forState: UIControlState.Normal)

          self.titleLabel?.font = UIFont.systemFontOfSize(fontSize)

     }
}





















































